package cn.buk.flight.entity;

import java.util.Date;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import jakarta.persistence.Transient;
import jakarta.persistence.UniqueConstraint;

/**
 * 航线表
 */
@Entity
@Table(name="airline_table", uniqueConstraints = @UniqueConstraint(name="uk_airline", columnNames = {"carrier", "dport", "aport"}))
public class AirlineTable {

	@Id
	@GeneratedValue(strategy= GenerationType.IDENTITY)
	private int id;

	@Column(length = 2)
	private String carrier;

	@Column(length=3)
	private String dport;
	
	@Column(length=3)
	private String aport;

	@Column(name = "flight_count")
	private Integer flightCount;
	
    @Temporal(TemporalType.TIMESTAMP)
	private Date lastupdate;


	//以下是用于计算Q+Q价格的临时的字段
	@Transient
	private String aport2;
	@Transient
	private int yprice;
	@Transient
	private int qprice;
	@Transient
	private int difference;

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the lastupdate
	 */
	public Date getLastupdate() {
		return lastupdate;
	}

	/**
	 * @param lastupdate the lastupdate to set
	 */
	public void setLastupdate(Date lastupdate) {
		this.lastupdate = lastupdate;
	}

	public String getCarrier() {
		return carrier;
	}

	public void setCarrier(String carrier) {
		this.carrier = carrier;
	}

	public String getDport() {
		if (dport == null) {
			return "";
		}
		return dport.trim();
	}

	public void setDport(String dport) {
		this.dport = dport;
	}

	public String getAport() {
		if (aport == null) {
			return "";
		}
		return aport.trim();
	}

	public void setAport(String aport) {
		this.aport = aport;
	}

	public Integer getFlightCount() {
		if (flightCount == null) {
			return 0;
		}
		return flightCount;
	}

	public void setFlightCount(Integer flightCount) {
		this.flightCount = flightCount;
	}

	public String getAport2() {
		return aport2;
	}

	public void setAport2(String aport2) {
		this.aport2 = aport2;
	}

	public int getYprice() {
		return yprice;
	}

	public void setYprice(int yprice) {
		this.yprice = yprice;
	}

	public int getQprice() {
		return qprice;
	}

	public void setQprice(int qprice) {
		this.qprice = qprice;
	}

	public int getDifference() {
		return difference;
	}

	public void setDifference(int difference) {
		this.difference = difference;
	}
}
